package com.dragon.app.um.vo;

import java.io.Serializable;
import java.util.HashMap;

import com.fintech.common.enums.ReturnCode;

public class JsonResult<T>  implements Serializable{
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	private String errorCode=ReturnCode.success.getErrorCode();
	/**
	 * 
	 */
	private String message;
	private T data;
	
	public String getErrorCode() {
		return errorCode;
	}
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	
	
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}
	
	public JsonResult(String errorCode, String message, T data) {
		super();
		this.errorCode = errorCode;
		this.message = message;
		this.data = data;
	}
	public JsonResult() {
		super();
	}
	public static JsonResult<Object> getResult(String errorCode ,String message ,Object data){
		JsonResult<Object> jsonResult = new JsonResult<Object>();
		jsonResult.setData(data);
		jsonResult.setErrorCode(errorCode);
		jsonResult.setMessage(message);
		if(data == null) data = new HashMap<String, Object>();
		jsonResult.setData(data);
		return jsonResult;
	}
	
	public void setErrorMsg(String msg){
		this.errorCode=ReturnCode.fail.getErrorCode();
		this.message=msg;
	}
	public void setErrorMsg(String code,String msg){
		this.errorCode=code;
		this.message=msg;
	}
}
